package com.zr.repertory.warearea.mapper;

import com.zr.warehouse.pojo.WarehouseSelectVo;
import com.zr.warehouse.pojo.WarehouseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * Created by HXH on 2019/11/21 0021.
 */
@Mapper
public interface WarehouseMapper {

    int queryCount(WarehouseSelectVo warehouseSelectVo);

    List<WarehouseVo> queryData(WarehouseSelectVo warehouseSelectVo);

    void addWarehouseVo(WarehouseVo warehouseVo);

    @Select("select count(warehouseId) from warehouse where warehouseCode=#{warehouseCode}")
    int queryByWarehouseCode(String warehouseCode);

    @Select("select count(warehouseId) from warehouse where warehouseName=#{warehouseName}")
    int queryByWarehouseName(String warehouseName);

    @Select("select * from warehouse where warehouseId=#{warehouseId}")
    WarehouseVo beforeupdate(Integer warehouseID);

    @Update("update warehouse set warehouseName=#{warehouseName},warehouseDec=#{warehouseDec},warehouseStatus=#{warehouseStatus}," +
            "warehouseMarkId=#{warehouseMarkId},warehouseAddress=#{warehouseAddress},createName=#{createName},createTime=#{createTime},updateName=#{updateName},updateTime=#{updateTime},version=#{version}+1 where id=#{id} and version=#{version} ")
    int update(WarehouseVo warehouseVo);

    @Select("select * from warehouse where warehouseName=#{warehouseName}")
    WarehouseVo queryByName1(String warehouseName);
}
